#
# @lc app=leetcode.cn id=697 lang=python
#
# [697] 数组的度
#

# @lc code=start
class Solution(object):
    def findShortestSubArray(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        # 找出众数
        result=len(nums)
        currntMax=0
        maxs={}
        for value in nums:
            if maxs.get(value):
                continue
            count=nums.count(value)
            maxs[value]=count
        # 找出众数的起点和终点
        for key in maxs.keys():
            if maxs.get(key)>=currntMax:
                start=nums.index(key)
                reversed_list = nums[::-1]
                end =reversed_list.index(key)
                print(key,maxs.get(key),start,end)
                result=min(result,len(nums)-end-start) if maxs.get(key)==currntMax else len(nums)-end-start
                currntMax=maxs.get(key)
            
        return result
# @lc code=end

